﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ImageView
{
    /// <summary>
    /// Interaction logic for ViewList.xaml
    /// </summary>
    public partial class ViewList : UserControl, IViev
    {
        public ViewList()
        {
            InitializeComponent();
        }

        private string[] _items;

        public void ClearItems()
        {
            LV.Items.Clear();
        }

        public void Fill(string[] Items)
        {
            _items = Items;
            ListBoxItem lvi;
            foreach (var item in Items)
            {
                lvi = new ListBoxItem();
                lvi.Content = System.IO.Path.GetFileName(item);
                LV.Items.Add(lvi);
            }
            ImageCount.Text = Items.Length.ToString();
        }

        public int SelectedIndex
        {
            get { return LV.SelectedIndex; }
        }

        private void LV_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (LV.SelectedItem != null)
            {
                if (App.MainWin.IsVideo(_items[LV.SelectedIndex])) App.MainWin.SwitchtoVideoView(LV.SelectedIndex);
                else App.MainWin.SwitchtoImageView(LV.SelectedIndex);
            }
        }
    }
}
